/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2017 Albert Mink
 *  E-mail contact: info@openlb.net
 *  The most recent release of OpenLB can be downloaded at
 *  <http://www.openlb.net/>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public
 *  License along with this program; if not, write to the Free
 *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA  02110-1301, USA.
*/

/** \file
 *  -- generic code
 */
#ifndef RTLBM_DESCRIPTORS_HH
#define RTLBM_DESCRIPTORS_HH

#include "rtlbmDescriptors.h"

namespace olb {
namespace descriptors {

// D3Q7 lattice for radiative transport problems @2016 A. Mink et al.
template<typename T>
const int D3Q7DescriptorBaseRTLBM<T>::c[D3Q7DescriptorBaseRTLBM<T>::q][D3Q7DescriptorBaseRTLBM<T>::d] = {
  { 0, 0, 0},

  {-1, 0, 0}, {0,-1, 0},
  { 0, 0,-1}, {1, 0, 0},
  { 0, 1, 0}, {0, 0, 1},
};

template<typename T>
const int D3Q7DescriptorBaseRTLBM<T>::opposite[D3Q7DescriptorBaseRTLBM<T>::q] = {
  0, 4, 5, 6, 1, 2, 3
};

template<typename T>
const int D3Q7DescriptorBaseRTLBM<T>::vicinity = 1;

template<typename T>
const T D3Q7DescriptorBaseRTLBM<T>::invCs2 = (T)4;

template<typename T>
const T D3Q7DescriptorBaseRTLBM<T>::t[D3Q7DescriptorBaseRTLBM<T>::q] = {
  (T)1-(T)3 / invCs2,

  (T)1/(invCs2*(T)2), (T)1/(invCs2*(T)2), (T)1/(invCs2*(T)2),
  (T)1/(invCs2*(T)2), (T)1/(invCs2*(T)2), (T)1/(invCs2*(T)2)
};

///g=0
template<typename T>
const double D3Q7DescriptorBaseRTLBM<T>::henyeyPhaseFunction[D3Q7DescriptorBaseRTLBM<T>::q][D3Q7DescriptorBaseRTLBM<T>::q] = {
  {0, 0, 0, 0, 0, 0, 0},
  {0, 4./3, 4./3., 4./3., 4./3., 4./3., 4./3.},
  {0, 4./3.,  4./3.,  4./3.,  4./3.,  4./3.,  4./3.},
  {0, 4./3.,  4./3.,  4./3.,  4./3.,  4./3.,  4./3.},
  {0, 4./3.,  4./3.,  4./3.,  4./3.,  4./3.,  4./3.},
  {0, 4./3.,  4./3.,  4./3.,  4./3.,  4./3.,  4./3.},
  {0, 4./3.,  4./3.,  4./3.,  4./3.,  4./3.,  4./3.}
};



// RTLB D3Q19 ////////////////////////////////////////////////////

template<typename T>
const int D3Q19DescriptorBaseRTLBM<T>::c[D3Q19DescriptorBaseRTLBM<T>::q][D3Q19DescriptorBaseRTLBM<T>::d] = {
  { 0, 0, 0},

  {-1, 0, 0}, { 0,-1, 0}, { 0, 0,-1},
  {-1,-1, 0}, {-1, 1, 0}, {-1, 0,-1},
  {-1, 0, 1}, { 0,-1,-1}, { 0,-1, 1},

  { 1, 0, 0}, { 0, 1, 0}, { 0, 0, 1},
  { 1, 1, 0}, { 1,-1, 0}, { 1, 0, 1},
  { 1, 0,-1}, { 0, 1, 1}, { 0, 1,-1}
};

template<typename T>
const int D3Q19DescriptorBaseRTLBM<T>::opposite[D3Q19DescriptorBaseRTLBM<T>::q] = {
  0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 1, 2, 3, 4, 5, 6, 7, 8, 9
};

template<typename T>
const int D3Q19DescriptorBaseRTLBM<T>::vicinity = 1;

template<typename T>
const T D3Q19DescriptorBaseRTLBM<T>::invCs2 = (T)3;

template<typename T>
const T D3Q19DescriptorBaseRTLBM<T>::t[D3Q19DescriptorBaseRTLBM<T>::q] = {
  (T)1/(T)3,

  (T)1/(T)18, (T)1/(T)18, (T)1/(T)18,
  (T)1/(T)36, (T)1/(T)36, (T)1/(T)36,
  (T)1/(T)36, (T)1/(T)36, (T)1/(T)36,

  (T)1/(T)18, (T)1/(T)18, (T)1/(T)18,
  (T)1/(T)36, (T)1/(T)36, (T)1/(T)36,
  (T)1/(T)36, (T)1/(T)36, (T)1/(T)36
};


///g=0
template<typename T>
const double D3Q19DescriptorBaseRTLBM<T>::henyeyPhaseFunction[D3Q19DescriptorBaseRTLBM<T>::q][D3Q19DescriptorBaseRTLBM<T>::q] = {
  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5},
  {0, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5},
  {0, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5},
  {0, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5},
  {0, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5},
  {0, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5},
  {0, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5},
  {0, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 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orBaseRTLBM<T>::vicinity = 1;

template<typename T>
const int D3Q27DescriptorBaseRTLBM<T>::c
[D3Q27DescriptorBaseRTLBM<T>::q][D3Q27DescriptorBaseRTLBM<T>::d] = {
  {0,0,0},
  {-1, 0, 0}, { 0,-1, 0}, { 0, 0,-1},
  {-1,-1, 0}, {-1, 1, 0}, {-1, 0,-1},
  {-1, 0, 1}, { 0,-1,-1}, { 0,-1, 1},
  {-1,-1,-1}, {-1,-1, 1}, {-1, 1,-1}, {-1, 1, 1},

  { 1, 0, 0}, { 0, 1, 0}, { 0, 0, 1},
  { 1, 1, 0}, { 1,-1, 0}, { 1, 0, 1},
  { 1, 0,-1}, { 0, 1, 1}, { 0, 1,-1},
  { 1, 1, 1}, { 1, 1,-1}, { 1,-1, 1}, { 1,-1,-1}
};

template<typename T>
const T D3Q27DescriptorBaseRTLBM<T>::invCs2 = (T)3;

template<typename T>
const int D3Q27DescriptorBaseRTLBM<T>::opposite[D3Q27DescriptorBaseRTLBM<T>::q] = {
  0,
  14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13
};

template<typename T>
const T D3Q27DescriptorBaseRTLBM<T>::t[D3Q27DescriptorBaseRTLBM<T>::q] = {
  T(0.0),
  (T)1/(T)21, (T)1/(T)21, (T)1/(T)21,
  (T)4/(T)105, (T)4/(T)105, (T)4/(T)105,
  (T)4/(T)105, (T)4/(T)105, (T)4/(T)105,
  (T)9/(T)280, (T)9/(T)280, (T)9/(T)280, (T)9/(T)280,

  (T)1/(T)21, (T)1/(T)21, (T)1/(T)21,
  (T)4/(T)105, (T)4/(T)105, (T)4/(T)105,
  (T)4/(T)105, (T)4/(T)105, (T)4/(T)105,
  (T)9/(T)280, (T)9/(T)280, (T)9/(T)280, (T)9/(T)280
};

template<typename T>
const double D3Q27DescriptorBaseRTLBM<T>::henyeyPhaseFunction[D3Q27DescriptorBaseRTLBM<T>::q][D3Q27DescriptorBaseRTLBM<T>::q] = {
//N100, g0
  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0, 1, 1, 1, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.577350269189626, 0.577350269189626, 0.577350269189626, 0.577350269189626, 1, 1, 1, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.577350269189626, 0.577350269189626, 0.577350269189626, 0.577350269189626},
  {0, 1, 1, 1, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.577350269189626, 0.577350269189626, 0.577350269189626, 0.577350269189626, 1, 1, 1, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.577350269189626, 0.577350269189626, 0.577350269189626, 0.577350269189626},
  {0, 1, 1, 1, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.577350269189626, 0.577350269189626, 0.577350269189626, 0.577350269189626, 1, 1, 1, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.577350269189626, 0.577350269189626, 0.577350269189626, 0.577350269189626},
  {0, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726},
  {0, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726},
  {0, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726},
  {0, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726},
  {0, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726},
  {0, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726},
  {0, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1},
  {0, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1},
  {0, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1},
  {0, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1},
  {0, 1, 1, 1, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.577350269189626, 0.577350269189626, 0.577350269189626, 0.577350269189626, 1, 1, 1, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.577350269189626, 0.577350269189626, 0.577350269189626, 0.577350269189626},
  {0, 1, 1, 1, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.577350269189626, 0.577350269189626, 0.577350269189626, 0.577350269189626, 1, 1, 1, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.577350269189626, 0.577350269189626, 0.577350269189626, 0.577350269189626},
  {0, 1, 1, 1, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.577350269189626, 0.577350269189626, 0.577350269189626, 0.577350269189626, 1, 1, 1, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.707106781186548, 0.577350269189626, 0.577350269189626, 0.577350269189626, 0.577350269189626},
  {0, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726},
  {0, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726},
  {0, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726},
  {0, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726},
  {0, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726},
  {0, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726, 1.41421356237310, 1.41421356237310, 1.41421356237310, 1, 1, 1, 1, 1, 1, 0.816496580927726, 0.816496580927726, 0.816496580927726, 0.816496580927726},
  {0, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1},
  {0, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1},
  {0, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1},
  {0, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1, 1.73205080756888, 1.73205080756888, 1.73205080756888, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1.22474487139159, 1, 1, 1, 1}
};

}  // namespace descriptors

}  // namespace olb

#endif
